#ifndef QIPAN_H
#define QIPAN_H
#include <QObject>
#include <QPaintEvent>
#include <QPainter>
#include <QWidget>
#include <QVector>
#include <QPair>
#include "stdshared.h"
class qipan : public QWidget
{
    Q_OBJECT
public:
    explicit qipan(QWidget *parent = nullptr);
public:
    /*记录棋盘位置对应的玩家*/
    void setBoardInfo(int row,int col,Role role);
    /*得到棋盘的信息*/
    Role ** getBoardInfo(int & boardSize)const;
    /*获取棋盘尺寸*/
    int getBoardSize();
protected:
    /*绘画事件*/
    void paintEvent(QPaintEvent *event);
    /*鼠标移动事件*/
    void mouseMoveEvent(QMouseEvent *event);
    /*鼠标点击事件*/
    void mousePressEvent(QMouseEvent *event);

signals:
    /*发送落子信号*/
    void chessClick(int row,int col);

public slots:
private:
    static const int m_boardSize = 15;//棋盘大小
    static const int m_cellSize = 40;//每个单元格的像素大小
    static const int m_margin = m_cellSize /2; //边缘
    
    /*玩家是1，人机是2*/
//    Role m_board[m_boardSize][m_boardSize];
    Role **m_board;
//    QVector<QPair<int,int>> m_board;
    /*悬停坐标*/
    int m_hoverRow;
    int m_hoverCol;
    bool m_hoverFlag;
    bool m_pressFlag;
};

#endif // QIPAN_H
